#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 505;
const int M = 2005;

int n, m;
int f[N], d[N], t[N];
void init(int n) { rep(i, 0, n - 1) f[i] = i, d[i] = 0; }
int find(int x) {
  if (f[x] == x) return x;
  int y = find(f[x]);
  d[x] = (d[x] + d[f[x]]) % 3;
  return f[x] = y;
}
bool merge(int x, int y, int z) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return (d[y] - d[x] + 3) % 3 == z;
  d[fy] = (d[x] + z - d[y] + 3) % 3;
  f[fy] = fx;
  return true;
}
struct Node {
  int x, y, z;
} a[M];
int test(int id) {
  init(n);
  rep(i, 1, m) {
    if (a[i].x == id || a[i].y == id) continue;
    if (!merge(a[i].x, a[i].y, a[i].z)) return i;
  }
  return m + 1;
}
void solve() {
  if (n == 1) {
    cout << "Player 0 can be determined to be the judge after 0 lines" << endl;
    return;
  }
  int num = test(-1);
  if (num > m) {
    cout << "Can not determine" << endl;
    return;
  } else {
    rep(i, 0, n - 1) t[i] = test(i);
    int cnt = 0;
    rep(i, 0, n - 1) if (t[i] == m + 1) cnt++;
    if (cnt > 1)
      cout << "Can not determine" << endl;
    else if (cnt < 1)
      cout << "Impossible" << endl;
    else {
      int id = -1;
      int mx = 0;
      rep(i, 0, n - 1) {
        if (t[i] == m + 1)
          id = i;
        else
          mx = max(mx, t[i]);
      }
      cout << "Player " << id << " can be determined to be the judge after "
           << mx << " lines" << endl;
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> n >> m) {
    rep(i, 1, m) {
      char op;
      cin >> a[i].x >> op >> a[i].y;
      if (op == '=') a[i].z = 0;
      if (op == '<') a[i].z = 1;
      if (op == '>') a[i].z = 2;
    }
    solve();
  }
  return 0;
}